alias ros="conda activate ros"
alias base="conda activate base"

source /opt/ros/melodic/setup.bash

rospymode(){
    echo "==================================================================="
    echo -e "\e[1;32m Switching *Python Env* to ros in conda\e[0m"
    ros
    echo "==================================================================="
    echo -e "\e[1;32m Changing mode of scripts in workspace\e[0m"
    echo "==================================================================="
    dir=`pwd`
    for file in $dir/src/*; do
	if [ -d $file ]; then
	    if [ -e $file/scripts ]; then
	        echo " Change mode +x for file in ${file}"
	        chmod +x $file/scripts/*
	    else
		echo " Skipping, ${file} doesn't exist"
	    fi
	fi
    done
    echo "==================================================================="
    echo -e "\e[1;32m Sourcing devel/setup.bash... \e[0m"
    if [ -e $dir/devel/setup.bash ]; then
        t=`source $dir/devel/setup.bash`
	source $dir/devel/setup.bash
    else
	echo " Skip: ${dir}/devel/setup.bash not exists"
    fi
    echo -e "\e[1;33m First running a new-built package may not have completaion\e[0m"
    echo "==================================================================="
}


rospy2run(){
    echo "==================================================================="
    echo -e "\e[1;32m Switching *Python Env* to system default (2.7 for ros) in conda\e[0m"
    conda deactivate
    conda deactivate
    echo "==================================================================="
}

alias pymod="rospymode"
alias mod="rospymode"
alias py2run="rospy2run"
export EDITOR="code -w"
